package com.Apo1o.controller;

import com.Apo1o.bean.ManagerFenceHouse;
import com.Apo1o.response.Result;
import com.Apo1o.response.ResultCode;
import com.Apo1o.service.IFenceHouseService;
import io.swagger.models.auth.In;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @Auther: Apo1o.
 * @Date: 2023/10/31-10-31-14:45
 * @Description： com.Apo1o.controller 栏舍管理
 */

@RestController
@RequiredArgsConstructor
@RequestMapping("fenceHouse")
@CrossOrigin
public class FenceHouseController {
    private final IFenceHouseService iFenceHouseService;
    @GetMapping("queryAll")
    public Result queryAll(){
        return Result.success(iFenceHouseService.rnm());
    }
@GetMapping()
    public Result query(Integer pageNum, Integer pageSize, String fhName){

    return Result.success(iFenceHouseService.query(pageNum,pageSize,fhName));
}
@DeleteMapping("deleteById/{id}")
    public Result deleteById(@PathVariable String id){
    iFenceHouseService.deleteById(id);
    return Result.success("删除成功");
}
@DeleteMapping("deleteByIdAll")
    public Result deleteByIdAll(@RequestBody List<String> list){
    iFenceHouseService.deleteByBatch(list);
    return Result.success("删除成功");
}
@PostMapping("saveOrUpdate")
    public Result saveOrUpdate(@RequestBody ManagerFenceHouse managerFenceHouse){
    iFenceHouseService.saveOrUpdate(managerFenceHouse);
    return Result.success();
}
@GetMapping("selectById")
    public Result selectById(String fhId){
    return Result.success(  iFenceHouseService.selectById(fhId));
}

}
